package com.example.JPetStore.common;

import com.example.JPetStore.Common;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
//    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public ModelAndView handleUserNotExistsException(Exception e) {
        ModelAndView mv = new ModelAndView();
        e.printStackTrace();
        Common.sendErrorMessage(mv, e.getMessage(), "/catalog/MainController");
        return mv;
    }
}
